/*
 * Copyright (C) 2007 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.android;

import android.os.Bundle;
import android.app.Dialog;
import android.content.Context;
import android.graphics.*;
import android.view.MotionEvent;
import android.view.View;
import android.widget.Button;
import android.widget.Toast;
import org.me.counttimer.R;

public class NumberPickerDialog extends Dialog {

    public interface OnNumberSelected {
        void numberSelected(int number);
    }

    private OnNumberSelected mListener;
    private int mInitialNumber;

    public NumberPickerDialog(Context context,
                             OnNumberSelected listener,
                             int number) {
        super(context);

        mListener = listener;
        mInitialNumber = number;
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        OnNumberSelected l = new OnNumberSelected() {
            public void numberSelected(int number) {
                mListener.numberSelected(number);
                dismiss();
            }
        };

        //setContentView(new ColorPickerView(getContext(), l, mInitialColor));

        setContentView(R.layout.number_picker_dialog);

        NumberPicker NumberPickerI = (NumberPicker) findViewById(R.id.pref_num_picker) ;
        NumberPickerI.setCurrent(mInitialNumber) ;

        Button OkButton = (Button) this.findViewById(R.id.ok_btn) ;
        OkButton.setOnClickListener(new View.OnClickListener() {
          public void onClick(View view) {
            NumberPicker NumberPickerI = (NumberPicker) findViewById(R.id.pref_num_picker) ;

            mListener.numberSelected(
                    NumberPickerI.getCurrent());
            dismiss();
          }
        });

        Button CancelButton = (Button) this.findViewById(R.id.cancel_btn) ;
        CancelButton.setOnClickListener(new View.OnClickListener() {
          public void onClick(View view) {
            dismiss();
          }
        });








        //setTitle(getString(R.string.repeat_for));
        setTitle("Pick a Number");
    }
}